<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('身份认证列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <label>社工昵称: </label>
                            <input type="text" name="wName" placeholder="请输入社工昵称">
                        </li>
                        <li>
                            <label>认证姓名：</label>
                            <input type="text" name="name" placeholder="请输入认证姓名"/>
                        </li>
                        <li>
                            <label>身份证号：</label>
                            <input type="text" name="code" placeholder="请输入身份证号"/>
                        </li>
                        <li>
                            <label>邀请人电话：</label>
                            <input type="text" name="inviter" placeholder="请输入邀请人电话"/>
                        </li>

                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <!--                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="jiajia:renZheng:add">-->
            <!--                    <i class="fa fa-plus"></i> 添加-->
            <!--                </a>-->
            <!--                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="jiajia:renZheng:edit">-->
            <!--                    <i class="fa fa-edit"></i> 修改-->
            <!--                </a>-->
<!--                            <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="jiajia:renZheng:remove">-->
<!--                                <i class="fa fa-remove"></i> 删除-->
<!--                            </a>-->
                            <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="jiajia:renZheng:export">
                                <i class="fa fa-download"></i> 导出
                            </a>
            <a class="btn btn-warning" onclick="makePayment()" shiro:hasPermission="jiajia:renZheng:makePayment">
                <i class="fa fa-download"></i> 打款
            </a>

        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('jiajia:renZheng:edit')}]];
    var removeFlag = [[${@permission.hasPermi('jiajia:renZheng:remove')}]];
    var prefix = ctx + "jiajia/renZheng";

    $(function () {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "身份认证",
            sortName:"addtime",
            sortOrder:"desc",
            columns: [
                {
                    field: 'id',
                    title: 'id',
                    visible: false
                },
                {
                    field: 'wName',
                    title: '社工昵称',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push(row.wName + '(' + row.wid + ')')
                        return actions.join('');
                    }
                },
                {
                    field: 'inviter',
                    title: '邀请人电话'
                },
                {
                    field: 'name',
                    title: '真实姓名'
                },
                {
                    field: 'code',
                    title: '身份证号'
                },
                {
                    field: 'codeAPhoto',
                    title: '身份证正面',
                    formatter: function (value, row, index) {
                        var url=row.codeAPhoto;
                        var actions = [];
                        actions.push('<img  src=' + url + ' style="width: 79px;height: 50px;" onclick="onLookPhotoListsClick(' + JSON.stringify(url).replace(/"/g, '&quot;') + ')" />');
                        return actions.join('');
                    }

                },
                {
                    field: 'codeBPhoto',
                    title: '身份证反面',
                    formatter: function (value, row, index) {
                        var actions = [];
                        var url=row.codeBPhoto;
                        actions.push('<img  src=' + url + ' style="width: 79px;height: 50px;" onclick="onLookPhotoListsClick(' + JSON.stringify(url).replace(/"/g, '&quot;') + ')" />');
                        return actions.join('');
                    }
                },
                {
                    field: 'authStatus',
                    title: '审核状态',
                    formatter: function (value, row, index) {
                        var actions = [];
                        if (row.authStatus == 0) {

                            actions.push('<i class="fa fa-edit" style="color: goldenrod">待审核</i>');

                        } else if (row.authStatus == 1) {

                            actions.push('<i class="fa fa-edit" style="color:#11bf79">已通过</i>');

                        } else actions.push('<i class="fa fa-edit" style="color: red">未通过</i>');

                        return actions.join('');
                    }

                },
                {
                    field: 'authCause',
                    title: '未通过原因',


                },
                {
                    field: 'addtime',
                    title: '添加时间'
                },
                {
                    field: 'payStatus',
                    title: '是否已打款',
                    formatter: function (value, row, index) {
                        var actions = [];
                        if (row.payStatus == 1) {
                            actions.push('<i class="fa fa-edit" style="color: goldenrod">已打款</i>');
                        } else if (row.payStatus == 2) {
                            actions.push('<i class="fa fa-edit" style="color:#11bf79">未打款</i>');
                        }

                        return actions.join('');
                    }

                },
                {
                    title: '审核',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        if (row.authStatus == 0) {
                            actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="onTongGuoClick(\'' + row.id + '\')"><i class="fa fa-check-square-o"></i>通过</a> ');
                            actions.push('<a class="btn btn-danger btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="unTongGuoClick(\'' + row.id + '\')"><i class="fa fa-times"></i>不通过</a>');
                        }
                        return actions.join('');
                    }

                },

            ]
        };
        $.table.init(options);
    });

    function onTongGuoClick(id) {
        var data = {
            "id": id,
            "authStatus": 1,
            "authCause": ""
        }
        $.modal.confirm("确认通过吗?", function () {
            $.operate.submit(prefix + "/shenHeTongGuo", "post", "json", data, function (res) {

            });
        });
    }

    function unTongGuoClick(id) {

        layer.prompt({title: '请说明未通过原因，并确认', formType: 2}, function (text, index) {
            layer.close(index);
            var data = {
                "id": id,
                "authStatus": 2,
                "authCause": text
            }
            $.operate.submit(prefix + "/shenHeTongGuo", "post", "json", data, function (res) {

            });
        });
    }
    function onLookPhotoListsClick(url){
        var data = [];
        var json =  {"title":"","id":1,"start":0,"data":data};
        data.push({"alt":"","pid":0,"src":url,"thumb":url});

        layer.photos({
            photos: json
            ,anim: 5
        });
    }

    function makePayment(){
        var data = [];
        var json =  {"title":"","id":1,"start":0,"data":data};
        data.push({"alt":"","pid":0,"src":url,"thumb":url});

        layer.photos({
            photos: json
            ,anim: 5
        });
    }


</script>
</body>
</html>
